<template>
	<view class="system-setting">
		<common-navbar title="系统设置" />
		<view class="user-info-container" style="margin-top: 16rpx;">
			<cell-item title="个人信息" :label="userInfo?'去编辑':'去登录'" :strong="true" titleColor="#1d1d1f"
				@click="userInfo?$u.route('/pages/authentication/authentication?isEdit=true'):$u.route('/pages_login/login_entry/loginEntry')">
			</cell-item>
		</view>
		<view class="other-setting-container" style="margin-top: 32rpx;">
			<template v-for="(item,index) in menuList">
				<cell-item :title="item.title" :label="item.label" :strong="item.strong"
					:titleColor="item.strong?'#1d1d1f':'#999999'" :titleFontsize="28" :key="index"
					@click="onClick(index)" v-if="item.needLogin?userInfo?true:false:true"
					:isShowArrow="!item.hideArrow" />
			</template>

		</view>
		<button class="logout-btn" @click="logout">退出登录</button>
	</view>
</template>

<script>
	import cellItem from "@/components/cell-item/cellItem";
	export default {
		components: {
			cellItem
		},
		data() {
			return {
				menuList: [{
						title: '其他',
						label: '',
						strong: true,
						hideArrow: true,
					}, {
						title: '修改密码',
						label: ''
					}, {
						title: '隐私协议',
						label: ''
					},
					// {
					// 	title: '账号注销',
					// 	label: '',
					// 	needLogin: true,
					// }, 
					{
						title: '关于小律懂法',
						label: `V${uni.getSystemInfoSync().appVersion}`,
					}
				]
			}
		},
		methods: {
			logout() {
				this.removeCurrentUserLabel();
				//删除token
				this.removeTokenSync();
				//删除环信token
				this.removeHXTokenSync();
				uni.WebIM.conn.close();
				uni.reLaunch({
					url: "/pages_login/login_entry/loginEntry"
				})
			},
			onClick(index) {
				if (index == 3) {
					this.$u.route('/pages/about_us/aboutUs');
				} else if (index == 1) {
					this.$u.route('/pages/resetPass/resetPass');
				} else if (index == 2) {
					this.$u.route('/pages/agreeandservices/privacyPolicy')
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./systemSetting.scss";
</style>
